<?php 
namespace Admin\Controller;
use Hdphp\Library\Controller;
/**
 * 
 * 
 * 后台用户
 */
class AdminController extends CommonController{


	public function index(){
		$user=M()->query("SELECT * FROM hd_admin");
		$this->assign('user',$user);
		$this->display();
	}

	//添加用户
	public function add_admin(){
		
		if(IS_POST){
			$passwd=md5($_POST['passwdF']);
			$title=$_POST['username'];

			$sql="INSERT INTO hd_admin SET username='{$title}', passwd='{$passwd}'";
			M()->exec($sql);
			$this->error('添加成功');
		}
		$this->display();
	}

	//锁定
	public function lock(){
		$aid=$_GET['aid'];
		$sql="UPDATE hd_admin SET hd_admin.lock=1 WHERE aid={$aid}";
		M()->exec();
		$this->error('锁定成功');		
	}

	//解锁
	public function unlock(){
		$aid=$_GET['aid'];
		$sql="UPDATE hd_admin SET hd_admin.lock=0 WHERE aid={$aid}";
		M()->exec();
		$this->error('解锁成功');
	}

}

 ?>